<template>
  <div class="app-container">
    <el-card>
      <el-form :model="queryParams" :inline="true" label-width="68px">
        <el-form-item label="单据号">
          <el-input
            v-model="queryParams.orderId"
            placeholder="请输入单号"
            clearable
            style="width: 240px"
          />
        </el-form-item>
        <el-form-item label="追溯码" prop="barCode">
          <el-input clearable placeholder="请输入追溯码" v-model="queryParams.barCode"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            @click="getCountQuery"
          >查询</el-button
          >
          <el-button type="danger" icon="el-icon-refresh" @click="clearAll"
          >重置</el-button
          >
        </el-form-item>
      </el-form>
    </el-card>
    <el-card>
      <el-table :data="kpiList" border height="calc(100vh - 300px)" :loading="loading">
        <el-table-column
          prop="ScanNum"
          label="扫码数量"
          align="center"></el-table-column>
        <el-table-column prop="OutBillDetailNum" align="center" label="出库明细数量"></el-table-column>
        <el-table-column prop="acceptStoreNum" label="验收明细数量" align="center"></el-table-column>
        <el-table-column prop="InUpStoreNum" label="入库明细数量" align="center"></el-table-column>
        <el-table-column prop="MoveNum" label="移库数量" align="center"></el-table-column>
        <el-table-column prop="UserName" label="操作人" align="center"></el-table-column>
        <el-table-column  label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" @click="handleEdit(scope.row)">
              详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        background
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        :page-sizes="[5, 10, 20, 50, 100]"
        :page-size="pageSize"
        :total="total"
      />
    </el-card>
  </div>
</template>
<script>
import {
  queryUserKpi
} from "@/api/storeM/yxl.js";

export default {
  name:'userKpi',
  data() {
    return {
      pageNum: 1,
      pageSize: 10,
      total: 0,
      kpiList: [],
      loading: false,
      queryParams:{
        barCode:'',
        orderId:'',
      }
    };
  },
  created() {
    this.getCountQuery();
  },
  methods: {
    //详情
    handleEdit(row){

    },
    // 查询列表
    getCountQuery() {
      const params = {
        pageNum: this.pageNum,
        pageSize: this.pageSize,
        ...this.queryParams
      };
      this.loading = true;
      queryUserKpi(params).then((response) => {
        this.kpiList = response.data.rows || [];
        this.total = response.data.total || 0;
      })
        .catch((error) => {
          this.$message.error("获取人员KPI信息失败");
        })
        .finally(() => {
          this.loading = false;
        });
    },

    // 分页大小变化
    handleSizeChange(newSize) {
      this.pageSize = newSize;
      this.getCountQuery();
    },

    // 当前页变化
    handleCurrentChange(newPage) {
      this.pageNum = newPage;
      this.getCountQuery();
    },

    // 重置搜索条件
    clearAll() {
      this.queryParams = {
        barCode:'',
        orderId:'',
      };
      this.pageNum = 1;
      this.pageSize = 10;
      this.getCountQuery();
    },
  },
};
</script>

<style scoped lang="scss">
.app-container {
  padding: 20px;
}

.el-card {
  margin-bottom: 20px;
}

.el-pagination {
  float: right;
  margin: 20px;
}

/* 自定义进度条样式 */
.el-progress-bar__inner {
  transition: width 0.6s ease;
}

.ml-2 {
  margin-left: 8px;
}
</style>
